home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dbase / techs.zip / TECH13.ZIP / CAPSTR.PRG next >
Text File  |  1985-11-01  |  994b  |  31 lines

  1. * Program ...: Capstr.PRG
  2. * Author ....: Christopher White
  3. * Date ......: July 1, 1985
  4. * Version ...: dBASE III, any version
  5. * Note(s)....: Capitalizes the first words in a string except
  6. *              for those speicified in an exception string.
  7. *
  8. PRIVATE string, fstring, word, exception
  9. PARAMETERS string
  10. * ---Initialize.
  11. string = LOWER( TRIM( string ) )  + SPACE( 2 )
  12. exception = "a an and for in or the "
  13. * ---Capitalize the first word.
  14. word = UPPER( SUBSTR( string,1,1 ) ) + SUBSTR( string,2,AT( " ",string ) - 1 )
  15. fstring = word
  16. string = SUBSTR( string,LEN( word ) + 1 )
  17. DO WHILE LEN( TRIM( string ) ) <> 0
  18.    * ---Capitalize the next word.
  19.    word = UPPER( SUBSTR( string,1,1 ) ) + SUBSTR( string,2,AT( " ",string ) - 1 )
  20.    * ---Test for exceptional words.
  21.    IF LOWER( word ) $ exception
  22.       word = LOWER( word )
  23.    ENDIF
  24.    fstring = fstring + word
  25.    string = SUBSTR( string,LEN( word ) + 1 )
  26. ENDDO
  27. string = TRIM( fstring )
  28. RETURN
  29. * EOP Capstr.PRG
  30.  
  31.